Skip to content

FloatLineEdit

Base classes

Name Children Inherits
LineEdit
prettyqt.widgets.lineedit
One-line text editor.

⋔ Inheritance diagram

graph TD
  1246779701["custom_widgets.FloatLineEdit"]
  1980365965["widgets.LineEdit"]
  829357528["widgets.WidgetMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  625385617["gui.PaintDeviceMixin"]
  1326755038["QtWidgets.QLineEdit"]
  3620195106["QtWidgets.QWidget"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  673956333["QtGui.QPaintDevice"]
  1980365965 --> 1246779701
  829357528 --> 1980365965
  3227531497 --> 829357528
  2751680898 --> 3227531497
  625385617 --> 829357528
  2751680898 --> 625385617
  2751680898 --> 829357528
  1326755038 --> 1980365965
  3620195106 --> 1326755038
  3984060476 --> 3620195106
  37984305 --> 3984060476
  2751680898 --> 37984305
  673956333 --> 3620195106
  37984305 --> 673956333

🛈 DocStrings

Bases: LineEdit

Source code in prettyqt/custom_widgets/editors/lineedits.py
class FloatLineEdit(widgets.LineEdit):
    value_changed = core.Signal(float)

    def __init__(self, *args, object_name: str = "float_lineedit", **kwargs):
        super().__init__(*args, object_name=object_name, **kwargs)
        self.set_validator("double", bottom=0.0)

    def get_value(self) -> float:
        val = super().get_value()
        try:
            return float(val)
        except ValueError:
            return 0.0

    def set_value(self, value: float | str):
        super().set_value(str(value))

    value = core.Property(
        float,
        get_value,
        set_value,
        doc="Current Value as float",
    )

:fa-brands-github: Show source on GitHub